package com.calligraphy.order.message;

import com.calligraphy.order.dto.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * Stream 接收端
 * @Author hy
 * @Date 2019/1/3 14:59
 **/
@Component
@Slf4j
@EnableBinding(StreamClient.class)
public class StreamReceiver {

/*    @StreamListener(StreamClient.OUTPUT)
    public void process(Object message){
        System.out.println("message:{}"+message);
    }*/

    /**
     * 接受Object对象
     * @param message
     */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.OUTPUT)
    public String process(OrderDTO message){
        System.out.println("接收message:{}"+message);
        return "success";
    }

    @StreamListener(StreamClient.OUTPUT)
    public void processOutput(OrderDTO message){
        System.out.println("返回message:{}"+message);
    }
}
